<template>
  <div class="dictionary">
    <DFPageList ref="dfPageListRef" :pageOptions="pageOptions" />
  </div>
</template>

<script lang="ts" setup name="Dictionary">
  import { useRouter } from 'vue-router';
  import lang from './lang';
  import { useMixins } from '@/hooks/useMixins';
  import { getDictTypeList,addDictType,updateDictType ,deleteDictType} from '@/api/system/dictionary';

  const { loadLangFn } = useMixins();
  loadLangFn(lang);
  const router = useRouter();
  const dfPageListRef: any = ref(null);

  const pageOptions = {
    searchForm: {
      formSchemas: [
        {
          component: 'NInput',
          label: 'dictTypeCode',
          prop:'dictionaryTypeCode',
        },
        {
          component: 'NInput',
          label: 'dictTypeName',
          prop:'dictionaryTypeName',
        },
      ],
    },
    table: {
      columns: [
        {
          width: 170,
          label: 'dictTypeCode',
          prop:'dictionaryTypeCode',
        },
        {
          width: 170,
          label: 'dictTypeName',
          prop:'dictionaryTypeName',
        },
      ],
      action: {
        columns: [
          {
            label: 'edit',
          },
          {
            label: 'delete',
          },
          {
            label: 'details',
            hump: true,
            click: (row) => {
              router.push({
                path: `/system/dictionary/check/${row.id}`,
                query: {
                  dictTypeCode: row.dictionaryTypeCode,
                },
              });
            },
          },
        ],
      },
      operaColumn: [
        {
          label: 'add',
        },
      ],
      requestFn: getDictTypeList,
      delRequestFn: deleteDictType,
    },
    modalFormDialog: {
      formSchemas: [
        {
          label: 'dictTypeCode',
          prop:'dictionaryTypeCode',
          editDialogDisabled: true,
          required: true,
        },
        {
          label: 'dictTypeName',
          prop:'dictionaryTypeName',
          required: true,
        },
        {
          label: 'remark',
          common: true,
          type: 'textarea',
        },
      ],
      addDataFn: addDictType,
      updateDataFn: updateDictType,

    },
  };
</script>
